package cs575.wido.action;

import java.awt.Component;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JOptionPane;

import cs575.wido.ui.GroupMemberViewer;

public class RemoveGroupMemberAction extends AbstractAction {
	private GroupMemberViewer parent;
	
	public RemoveGroupMemberAction(GroupMemberViewer parent) {
		putValue(NAME, "Remove");
		this.parent = parent;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		switch(JOptionPane.showConfirmDialog(parent, "Are you sure?", "Remove Member", JOptionPane.YES_NO_OPTION)) {
		case JOptionPane.YES_OPTION:
			int index = parent.getMemberList().getSelectedIndex();
			parent.getMemberListModel().remove(index);
			break;
		case JOptionPane.NO_OPTION:
			break;
		}
	}
}
